import { Controller, Req, Post, UseGuards,Get } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport'; // 确定请求是否由路由处理程序
import { AuthService } from './auth.service';
@Controller('auth')
export class AuthController {
  //  依赖注入
  constructor(
      private readonly authService: AuthService
   ){}
   //这个守卫中检查是否存在有效的 JWT
  @UseGuards(AuthGuard('local'))
  @Post('login')
  async login(@Req() req) {
    // 向有效用户发出 JWT 的步骤
    return this.authService.login(req.user);
  }
  @UseGuards(AuthGuard('jwt'))
  @Post('profile')
  getProfile(@Req() req) {
    return req.user;
  }
}
